# 需要安装的库
# pip install selenium
# pip install user_agent

"""
正向代理服务器，可以通过squid自己搭建，过程比较简单

"""

import os
import time
from selenium import webdriver
import user_agent

root_path = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

if __name__ == '__main__':
    chrome_options = webdriver.ChromeOptions()
    # chrome_options.add_extension()
    # chrome_options.add_argument('window-size=1200x600')
    # chrome_options.add_argument('--disable-gpu')
    # chrome_options.add_argument('--screenshot')
    chrome_options.add_argument("--proxy-server=http://192.168.0.1:8000/")
    # chrome_options.add_argument('--headless')
    # chrome_options.add_argument("--proxy-server=%s" % proxy)
    chrome_options.add_argument('user-agent="%s"' % user_agent.generate_user_agent())

    driver = webdriver.Chrome(executable_path=root_path + "/bin/chromedriver_win32_242.exe",
                              options=chrome_options)
    time.sleep(1)
    driver.get("https://www.baidu.com/")
    time.sleep(1)
    source = driver.page_source

    print(type(source),len(source),source)

    time.sleep(10000)


    driver.quit()


